package kael.aiur.dao.sqlserver;
 
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import kael.aiur.database.DBUtil;

public class SQLServer extends DBUtil{
	@Override
	public List<String> getColumns(ResultSet rs) {
		List<String> list = new ArrayList<String>();
		try {
			Field field = rs.getClass().getDeclaredField("columns");
			field.setAccessible(true);
			Object[] columns = (Object[]) field.get(rs);
			for(Object column : columns){
				Field columnName =column.getClass().getDeclaredField("columnName");
				columnName.setAccessible(true);
				list.add(columnName.get(column).toString());
			}
			return list;
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected String urlConnString() {
		return ";databaseName=";
	}

}
